package com.xmy.cultivate.mapper;

import com.xmy.cultivate.entity.SenateSubjectsProjects;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 教务科目项目（对应科目有哪些项目） Mapper 接口
 * </p>
 *
 * @author hpiggy
 * @since 2024-10-26
 */
public interface SenateSubjectsProjectsMapper extends BaseMapper<SenateSubjectsProjects> {


    @Select({"<script>",
            "SELECT",
                    "t1.projects_id AS id,",
                    "t2.`name` ",
                    "FROM",
                    "senate_subjects_projects AS t1",
                    "INNER JOIN dict AS t2 ON t1.projects_id = t2.num ",
                    "AND t2.type = 28 ",
                    "WHERE",
                    "t1.deleted = 0",
                    "and t1.year_part = ${yearPart}",
                    "and t1.quarter_num =${quarterNum} ",
                    "<when test='subjectsId!=null and subjectsId!=&apos;&apos; '>",
                    "and t1.subjects_id in(${subjectsId})",
                    "</when>",
                    "GROUP BY",
                    "projects_id ",
                    "ORDER BY",
                    "t1.sort,",
                    "t1.id ASC",
    "</script>"})
    public List<SenateSubjectsProjects> getPorjectList(@Param("yearPart") Integer yearPart,
                                                       @Param("quarterNum") Integer quarterNum,
                                                       @Param("subjectsId") String subjectsId
                                                       );

}
